// MainDlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include <atlddx.h>
#include <atlcrack.h>
#include "alway_regex.h"
void  throw_exception(class std::exception const &);
class CMainDlg : public CDialogImpl<CMainDlg>, public CUpdateUI<CMainDlg>,
	public CMessageFilter, public CIdleHandler,
	public CWinDataExchange<CMainDlg>,
	public CDialogResize<CMainDlg>
{
public:
	CString m_strSourceText;CString m_strResultText;CString m_strRegText;CString m_strReplaceText;



public:
	enum { IDD = IDD_MAINDLG };

	virtual BOOL PreTranslateMessage(MSG* pMsg);
	virtual BOOL OnIdle();

	BEGIN_UPDATE_UI_MAP(CMainDlg)
	END_UPDATE_UI_MAP()

	BEGIN_MSG_MAP(CMainDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
		COMMAND_ID_HANDLER(IDOK, OnOK)
		COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
		COMMAND_HANDLER_EX(IDC_BUTTON_MATCH, BN_CLICKED, OnButtonMatchBnClicked)
		COMMAND_HANDLER_EX(IDC_BUTTON_SEARCH, BN_CLICKED, OnButtonSearchBnClicked)
		COMMAND_HANDLER_EX(IDC_BUTTON_RELPACE, BN_CLICKED, OnButtonRelpaceBnClicked)
		COMMAND_HANDLER_EX(IDC_COMBO_SELECT_REGEX_EXAMPLE_TYPE, CBN_SELCHANGE, OnComboCityCbnSelChange)
		COMMAND_HANDLER_EX(IDC_BUTTON_LOOP_SEARCH, BN_CLICKED, OnButtonLoopSearchBnClicked)
		CHAIN_MSG_MAP(CDialogResize<CMainDlg>)
	END_MSG_MAP()

	BEGIN_DDX_MAP(CMainDlg)
		DDX_TEXT(IDC_EDIT_SOURCE_TEXT, m_strSourceText)
		DDX_TEXT(IDC_EDIT_RESULT_TEXT, m_strResultText)
		DDX_TEXT(IDC_EDIT_REG_TEXT, m_strRegText)
		DDX_TEXT(IDC_EDIT_REPLACE_TEXT, m_strReplaceText)
		//DDX_CONTROL(IDC_COMBO_SELECT_REGEX_EXAMPLE_TYPE, m_wndSelectRegexExampleType)
	END_DDX_MAP()

	BEGIN_DLGRESIZE_MAP(CMainDlg)
		//CStatic Source Regex Replace Result Text
		//BEGIN_DLGRESIZE_GROUP()
		  DLGRESIZE_CONTROL(IDC_STATIC_SOURCE_TEXT,DLSZ_REPAINT)
		  DLGRESIZE_CONTROL(IDC_STATIC_REGEX_TEXT, DLSZ_REPAINT)
		  DLGRESIZE_CONTROL(IDC_STATIC_REPLACE_TEXT, DLSZ_REPAINT)
		  DLGRESIZE_CONTROL(IDC_STATIC_RESULT_TEXT, DLSZ_REPAINT)
		//END_DLGRESIZE_GROUP()

		//BEGIN_DLGRESIZE_GROUP()
		  DLGRESIZE_CONTROL(IDC_EDIT_SOURCE_TEXT,DLSZ_SIZE_X)
		  DLGRESIZE_CONTROL(IDC_EDIT_REG_TEXT, DLSZ_SIZE_X)
		  DLGRESIZE_CONTROL(IDC_EDIT_REPLACE_TEXT, DLSZ_SIZE_X)
		  DLGRESIZE_CONTROL(IDC_EDIT_RESULT_TEXT, DLSZ_SIZE_X | DLSZ_SIZE_Y)
		//END_DLGRESIZE_GROUP()

		//BEGIN_DLGRESIZE_GROUP()
		  DLGRESIZE_CONTROL(IDC_BUTTON_MATCH,DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(IDC_BUTTON_SEARCH, DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(IDC_BUTTON_RELPACE, DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(IDOK, DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(IDCANCEL, DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(IDC_STATIC_SELECT_REGEX_TYPE, DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(IDC_COMBO_SELECT_REGEX_EXAMPLE_TYPE, DLSZ_MOVE_X)
		  DLGRESIZE_CONTROL(ID_APP_ABOUT, DLSZ_MOVE_X)
		//END_DLGRESIZE_GROUP()
	END_DLGRESIZE_MAP()

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

	void CloseDialog(int nVal);
	LRESULT OnButtonMatchBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);
	LRESULT OnButtonSearchBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);
	LRESULT OnButtonRelpaceBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);

	alway_regex alway_regex_;
	CComboBox m_wndSelectRegexExampleType;

	LRESULT OnComboCityCbnSelChange(WORD wNotifyCode, WORD wID, HWND hWndCtl); 

	LRESULT OnButtonLoopSearchBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl);
};
